﻿using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CutShuFa.AutoAction
{
    public abstract class AAutoAction : IAutoAction
    {
        protected List<Parameter> parameters = null;
        public List<Parameter> Parameters
        {
            get
            {
                return GetParameters();
            }

            set
            {
                parameters = value;
            }
        }
        public abstract string ActionName { get;}

        public abstract List<Parameter> GetParameters();

        public abstract void Run(AutoActionData data);

        public override string ToString()
        {
            return ActionName;
        }
        protected Scalar ToScalar(string color)
        {
            return new Scalar(Convert.ToInt32(color.Substring(1, 2), 16), Convert.ToInt32(color.Substring(3, 2), 16), Convert.ToInt32(color.Substring(5, 2), 16));
        }
        public Bitmap Mat2Bitmat(Mat mat)
        {
            return BitmapConverter.ToBitmap(mat);
        }
        public Mat Bitmat2Mat(Bitmap bitmap)
        {
            return bitmap.ToMat();
        }

    }
}
